diff options
| author | Adam Soltys <[email protected]> | 2024-09-06 09:32:53 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-09-17 09:18:36 -0700 |
| commit | 1b7cc6d64fb2ee3340a18d0924c4b64afabbc1e1 (patch) | |
| tree | 4498405ef5555a6680b36e9628806f497ec0f561 /src/routes/(app)/[username] | |
| parent | c5ef18aec5de023732eb6b86f768f206462fea93 (diff) | |
| download | coinos-ui-1b7cc6d64fb2ee3340a18d0924c4b64afabbc1e1.tar.gz coinos-ui-1b7cc6d64fb2ee3340a18d0924c4b64afabbc1e1.zip | |
per account payment pages
Diffstat (limited to 'src/routes/(app)/[username]')
9 files changed, 54 insertions, 66 deletions
diff --git a/src/routes/(app)/[username]/(profile)/+page.svelte b/src/routes/(app)/[username]/(profile)/+page.svelte index afb4e58c..7c0de9d8 100644 --- a/src/routes/(app)/[username]/(profile)/+page.svelte +++ b/src/routes/(app)/[username]/(profile)/+page.svelte @@ -23,11 +23,11 @@ $installPrompt = null; }; - user.savings = 0; + if (user) user.savings = 0; let accounts = [ { balance: user.balance, setup: true, type: "Cash" }, - { balance: user.savings, setup: false, type: "Savings" }, + { id: "pubtest", balance: user.savings, setup: !!user.seed, type: "Savings" }, ]; </script> diff --git a/src/routes/(app)/[username]/payments/[...page]/+page.server.ts b/src/routes/(app)/[username]/[...account]/payments/[...page]/+page.server.ts index 070349f8..070349f8 100644 --- a/src/routes/(app)/[username]/payments/[...page]/+page.server.ts +++ b/src/routes/(app)/[username]/[...account]/payments/[...page]/+page.server.ts diff --git a/src/routes/(app)/[username]/payments/[...page]/+page.svelte b/src/routes/(app)/[username]/[...account]/payments/[...page]/+page.svelte index 1efdc2ec..1efdc2ec 100644 --- a/src/routes/(app)/[username]/payments/[...page]/+page.svelte +++ b/src/routes/(app)/[username]/[...account]/payments/[...page]/+page.svelte diff --git a/src/routes/(app)/[username]/payments/[...page]/+server.ts b/src/routes/(app)/[username]/[...account]/payments/[...page]/+server.ts index a81faaf3..a81faaf3 100644 --- a/src/routes/(app)/[username]/payments/[...page]/+server.ts +++ b/src/routes/(app)/[username]/[...account]/payments/[...page]/+server.ts diff --git a/src/routes/(app)/[username]/receive/[...param]/+page.server.ts b/src/routes/(app)/[username]/[...account]/receive/[...param]/+page.server.ts index 502678a9..13eb1381 100644 --- a/src/routes/(app)/[username]/receive/[...param]/+page.server.ts +++ b/src/routes/(app)/[username]/[...account]/receive/[...param]/+page.server.ts @@ -2,16 +2,18 @@ import { redirect } from "@sveltejs/kit"; import { auth, post } from "$lib/utils"; import type { Invoice } from "$lib/types"; -export let load = async ({ cookies, parent }) => { +export let load = async ({ cookies, params, parent }) => { + let { account } = params; let {subject, user, rates } = await parent(); let invoice: Invoice = { - type: "lightning", + account, + type: account ? "bitcoin": "lightning", rate: rates[user?.currency || subject?.currency], }; if(!user) user = subject; - invoice = await post("/invoice", { invoice, user }, auth(cookies)); + invoice = await post("/invoice", { invoice, account, user }, auth(cookies)); let { id } = invoice; if (invoice.memoPrompt && !invoice.memo) { diff --git a/src/routes/(app)/[username]/receive/[...param]/+page.svelte b/src/routes/(app)/[username]/[...account]/receive/[...param]/+page.svelte index f9267105..f9267105 100644 --- a/src/routes/(app)/[username]/receive/[...param]/+page.svelte +++ b/src/routes/(app)/[username]/[...account]/receive/[...param]/+page.svelte diff --git a/src/routes/(app)/[username]/account/setup/+page.svelte b/src/routes/(app)/[username]/account/setup/+page.svelte index 5c2102c7..9636ff2a 100644 --- a/src/routes/(app)/[username]/account/setup/+page.svelte +++ b/src/routes/(app)/[username]/account/setup/+page.svelte @@ -32,8 +32,8 @@ </p> <p class="text-secondary mb-1"> - Whoever knows these words can withdraw funds from the account. We can't - help you recover them if you lose them. + Whoever knows these words in the correct order can withdraw funds from the account. We can't + recover them if you lose them. </p> {#if reveal} diff --git a/src/routes/(app)/[username]/account/setup/step2/+page.svelte b/src/routes/(app)/[username]/account/setup/step2/+page.svelte index 3b403295..d8f44e16 100644 --- a/src/routes/(app)/[username]/account/setup/step2/+page.svelte +++ b/src/routes/(app)/[username]/account/setup/step2/+page.svelte @@ -5,6 +5,8 @@ import { encrypt, decrypt } from "nostr-tools/nip49"; import { mnemonicToEntropy, entropyToMnemonic } from "@scure/bip39"; import { wordlist } from "@scure/bip39/wordlists/english"; + import { fail, post } from "$lib/utils"; + import { goto } from "$app/navigation"; export let data; let { user } = data; @@ -12,11 +14,14 @@ let password; let submit = async () => { - console.log($mnemonic); - let t = await encrypt(mnemonicToEntropy($mnemonic, wordlist), password); - - let m = await decrypt(t, password); - console.log(entropyToMnemonic(m, wordlist)); + user.seed = await encrypt(mnemonicToEntropy($mnemonic, wordlist), password); + try { + await post("/api/user", user); + goto(`/${user.username}`); + } catch (e) { + console.log(e); + fail("Something went wrong"); + } }; </script> diff --git a/src/routes/(app)/[username]/invoice/[id]/+page.svelte b/src/routes/(app)/[username]/invoice/[id]/+page.svelte index 28bfe27b..24e75fa5 100644 --- a/src/routes/(app)/[username]/invoice/[id]/+page.svelte +++ b/src/routes/(app)/[username]/invoice/[id]/+page.svelte @@ -28,7 +28,6 @@ export let data; - let ndef; let showOptions; let reading = async ({ message, serialNumber }) => { @@ -41,6 +40,7 @@ $: refresh(data); let { invoice, id, subject, user, src } = data; let { + account, amount, hash, type, @@ -56,6 +56,7 @@ let refresh = async (data) => { ({ invoice, id, user, src } = data); ({ + account, amount, hash, type, @@ -66,21 +67,6 @@ } = invoice); tipPercent = (tip / amount) * 100; - - // if (browser && window.NDEFReader) { - // try { - // ndef = new NDEFReader(); - // await ndef.scan(); - // - // ndef.removeEventListener('readingerror', readingerror); - // ndef.removeEventListener('reading', reading); - // - // ndef.addEventListener('readingerror', readingerror); - // ndef.addEventListener('reading', reading); - // } catch (e) { - // console.log(e); - // } - // } }; $: amountFiat = parseFloat(((amount * rate) / sats).toFixed(2)); @@ -100,13 +86,6 @@ } }); - onDestroy(() => { - if (ndef) { - ndef.removeEventListener("readingerror", readingerror); - ndef.removeEventListener("reading", reading); - } - }); - $: link = [types.bitcoin, types.liquid].includes(type) ? text : `lightning:${text}`; @@ -257,39 +236,41 @@ </div> </div> - <div class="flex justify-around text-secondary"> - <button - class="hover:bg-primary my-auto flex gap-1 sm:gap-2 py-3 px-2 sm:px-5 w-full justify-center" - class:bg-primary={type === types.bitcoin} - class:text-black={type === types.bitcoin} - on:click={() => setType(types.bitcoin)} - > - <img src="/images/bitcoin.svg" class="w-8" alt="Bitcoin" /> - <div class="my-auto text-lg">Bitcoin</div> - </button> + {#if !account} + <div class="flex justify-around text-secondary"> + <button + class="hover:bg-primary my-auto flex gap-1 sm:gap-2 py-3 px-2 sm:px-5 w-full justify-center" + class:bg-primary={type === types.bitcoin} + class:text-black={type === types.bitcoin} + on:click={() => setType(types.bitcoin)} + > + <img src="/images/bitcoin.svg" class="w-8" alt="Bitcoin" /> + <div class="my-auto text-lg">Bitcoin</div> + </button> - <button - class="hover:bg-primary my-auto flex gap-1 sm:gap-2 py-3 px-2 sm:px-5 w-full justify-center" - class:bg-primary={type === types.liquid} - class:text-black={type === types.liquid} - on:click={() => setType(types.liquid)} - > - <img src="/images/liquid.svg" class="w-8" alt="Liquid" /> - <div class="my-auto text-lg">Liquid</div> - </button> + <button + class="hover:bg-primary my-auto flex gap-1 sm:gap-2 py-3 px-2 sm:px-5 w-full justify-center" + class:bg-primary={type === types.liquid} + class:text-black={type === types.liquid} + on:click={() => setType(types.liquid)} + > + <img src="/images/liquid.svg" class="w-8" alt="Liquid" /> + <div class="my-auto text-lg">Liquid</div> + </button> - <button - class="hover:bg-primary flex gap-1 sm:gap-2 py-3 px-2 sm:px-5 w-full justify-center" - class:bg-primary={type === types.lightning} - class:text-black={type === types.lightning} - on:click={() => setType(types.lightning)} - > - <div class="bg-white rounded-full w-8 h-8 text-center flex"> - <div class="m-auto">⚡️</div> - </div> - <div class="my-auto text-lg">Lightning</div> - </button> - </div> + <button + class="hover:bg-primary flex gap-1 sm:gap-2 py-3 px-2 sm:px-5 w-full justify-center" + class:bg-primary={type === types.lightning} + class:text-black={type === types.lightning} + on:click={() => setType(types.lightning)} + > + <div class="bg-white rounded-full w-8 h-8 text-center flex"> + <div class="m-auto">⚡️</div> + </div> + <div class="my-auto text-lg">Lightning</div> + </button> + </div> + {/if} {#if type === types.liquid} <div class="flex justify-center"> |
